package com.tl.mq.rabbit_mq;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RabbitMqProducer {

    @Autowired
    private AmqpTemplate amqpTemplate;

    // 直接发送到队列
    public void sendQueue(String msg){
        amqpTemplate.convertAndSend("img",msg);
    }


    // 使用topic交换机，with
    public void sengTopicQueue(String msg){
        amqpTemplate.convertAndSend("exchange_topic","img_topic",msg);
    }

    // 使用fanout交换机，绑定的队列都发
    public void sendFanoutQueue(String msg){
        amqpTemplate.convertAndSend("exchange_fanout","",msg);
    }


}
